<template>
  <div>
    <svg-icon icon-class="info" class="navSvgSty" @click="click" />
  </div>
</template>

<script>
import eventBus from '../../api/information/eventBus.js'
export default {
  name: 'Announcement',
  data() {
    return {
      showView: false
    }
  },
  created() {
    eventBus.$on('showView', (message) => {
      // 接受点击公告按钮传过来的值
      this.showView = message
    })
  },
  /* 解绑eventBus事件*/
  beforeDestroy() {
    eventBus.$off('showView')
  },
  methods: {
    /* 公告喇叭按钮点击事件*/
    click() {
      this.showView = !this.showView
      eventBus.$emit('showView', this.showView)
      /* 如果切换到首页就显示公告，不用使用vuex可删除该句*/
      this.$store.commit('updateData', this.showView)
    }
  }
}
</script>
